#include "BatchDialog.h"

BatchDialog::BatchDialog(QWidget *parent) :
    QDialog(parent)
{
    initContent();
    initConnection();

}

void BatchDialog::initContent()
{
    verticalLayout = new QVBoxLayout(this);

    buttonPad = new ButtonPad(this);
    verticalLayout->addWidget(buttonPad);

    horizontalLayout = new QHBoxLayout;
    verticalLayout->addLayout(horizontalLayout);

    pushButtonCheckAll = new QPushButton(this);
    pushButtonCheckAll->setText(QString::fromUtf8(u8"全选"));
    horizontalLayout->addWidget(pushButtonCheckAll);

    pushButtonUncheckAll = new QPushButton(this);
    pushButtonUncheckAll->setText(QString::fromUtf8(u8"全部取消"));
    horizontalLayout->addWidget(pushButtonUncheckAll);

    checkBoxAutoFocus = new QCheckBox(this);
    checkBoxAutoFocus->setText(QString::fromUtf8(u8"自动对焦"));
    checkBoxAutoFocus->setCheckable(true);
    checkBoxAutoFocus->setChecked(true);
    horizontalLayout->addWidget(checkBoxAutoFocus);

    checkBoxAutoMeasure = new QCheckBox(this);
    checkBoxAutoMeasure->setText(QString::fromUtf8(u8"自动测量"));
    checkBoxAutoMeasure->setCheckable(true);
    checkBoxAutoMeasure->setChecked(false);
    horizontalLayout->addWidget(checkBoxAutoMeasure);

    checkBoxAutoCenter = new QCheckBox(this);
    checkBoxAutoCenter->setText(QString::fromUtf8(u8"自动居中"));
    checkBoxAutoCenter->setCheckable(true);
    checkBoxAutoCenter->setChecked(false);
    horizontalLayout->addWidget(checkBoxAutoCenter);
    horizontalLayout->addStretch(10);

    pushButtonOK = new QPushButton(this);
    pushButtonOK->setText(QString::fromUtf8(u8"确定"));
    horizontalLayout->addWidget(pushButtonOK);

    pushButtonReject = new QPushButton(this);
    pushButtonReject->setText(QString::fromUtf8(u8"取消"));
    horizontalLayout->addWidget(pushButtonReject);

    setLayout(verticalLayout);
}

void BatchDialog::initConnection()
{
    connect(pushButtonCheckAll,SIGNAL(clicked()), buttonPad, SLOT(checkAll()));
    connect(pushButtonUncheckAll, SIGNAL(clicked()), buttonPad, SLOT(uncheckAll()));
    connect(pushButtonOK,SIGNAL(clicked()), this, SLOT(accept()));
    connect(pushButtonReject, SIGNAL(clicked()), this, SLOT(reject()));
}

bool BatchDialog::autoFocus() const
{
    return checkBoxAutoFocus->isChecked();
}

bool BatchDialog::autoMeasure() const
{
    return checkBoxAutoMeasure->isChecked();
}

bool BatchDialog::autoCenter() const
{
    return checkBoxAutoCenter->isChecked();
}

bool BatchDialog::saveWithMark() const
{
    return 1;
}

BatchDialog::~BatchDialog()
{
    //delete buttonPad;
}

QVector<QPoint> BatchDialog::getMeasurePoints()
{
    return buttonPad->getChecked();
}
